//
//  VIZViewNavugationVC.swift
//  VIZ微博
//
//  Created by 位立志 on 16/4/8.
//  Copyright © 2016年 位立志. All rights reserved.
//

import UIKit

class VIZViewNavugationVC: UINavigationController,UIGestureRecognizerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        //print("viewwwwww")
        self.interactivePopGestureRecognizer?.delegate = self
    }
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count > 0 {
            var backTitle = "返回"
            if childViewControllers.count == 1{
                backTitle = childViewControllers.first?.title ?? ""
            }
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", title: backTitle, target: self, action: "back")
            //隐藏底部tabbar
            viewController.hidesBottomBarWhenPushed = true
            viewController.view.backgroundColor = UIColor.whiteColor()
        }
        super.pushViewController(viewController, animated: animated)
        //print(childViewControllers.count)

        
    }

    @objc private func back(){
        self.popViewControllerAnimated(true)
    }


    //手势将要开始的协议方法
    //协议方法返回值是 bool值 如果返回ture  就可以正常工作,如果返回false 手势就会失效
    func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
        //print("哈哈哈")
        return childViewControllers.count != 1
        //        if childViewControllers.count == 1 {
        //            return false
        //        }
        //        return true
    }





}
